<template>
  <div class="main">
    <div class="headerbox">
      <div class="header">
        <shopheader></shopheader>
      </div>

      <div class="shopmsg">
        <shopmsg :storeData="storeData"></shopmsg>
      </div>

      <div class="tab">
        <shoptab></shoptab>
      </div>
    </div>

    <div class="headeImg" v-if="form.storePicture">
      <img :src="form.storePicture" alt="" />
    </div>

    <div class="notifybox" v-if="form.storeNotice">
      <img class="line" src="../../assets/image/shop/line.png" alt="" />
      <img class="laba" src="../../assets/image/shop/laba.png" alt="" />
      <img class="notify" src="../../assets/image/shop/notify.png" alt="" />
      <div class="text">
        {{ form.storeNotice }}
      </div>
    </div>

    <div class="tuijianbox">
      <div class="header">
        <img src="../../assets/image/shop/tuijian.png" alt="" />
        <div class="text">商家精选店铺畅销高数据模式</div>
      </div>
      <div class="no"></div>
      <div class="productbox">
        <div
          class="tuiojianproduct"
          v-for="(item, index) in form.recommendProduct"
          :key="index"
        >
          <shopproduct :item="item"></shopproduct>
        </div>
      </div>
    </div>

    <div class="bottombox">
      <div class="leftmsg">
        <shopdetail :storeData="storeData"></shopdetail>
      </div>

      <div class="right">
        <div class="header">
          <div class="top">
            <div
              @click="getType(item,index)"
              class="item"
              :class="activeIndex == index ? 'activeitem' : ''"
              v-for="(item, index) in itemlist"
              :key="index"
            >
              {{ item.categoryName }}({{ item.productNumber }})
            </div>
          </div>

          <div class="screen">
            <div
              @click="getLx(index)"
              class="leftbox"
              :class="{ isactive: screenindex == index }"
              v-for="(item, index) in screenlist"
              :key="index"
            >
              {{ item }}
              <div class="sanjiao" v-if="item == '价格'">
                <div
                  class="topsnjiao"
                  :class="{ isSan: screenindex == 3 }"
                  @click="getLx(3)"
                ></div>
                <div
                  @click="getLx(4)"
                  class="bottomsanjiao"
                  :class="{ isSan: screenindex == 4 }"
                ></div>
              </div>
            </div>
            <div class="leftbox">
              价格
              <div class="sanjiao">
                <div
                  class="topsnjiao"
                  :class="{ isSan: screenindex == 3 }"
                  @click="getLx(3)"
                ></div>
                <div
                  @click="getLx(4)"
                  class="bottomsanjiao"
                  :class="{ isSanB: screenindex == 4 }"
                ></div>
              </div>
            </div>
            <div class="rightbox">
              <!-- <div class="zdj">最低价</div>
              ~
              <div class="zgj">最高价</div> -->
              <div class="search">
                <el-input
                  class="inputStyle"
                  v-model="input"
                  style="width: 0.75rem"
                  placeholder="最低价"
                ></el-input>
                至
                <el-input
                  class="inputStyle"
                  v-model="input1"
                  placeholder="最高价"
                  style="width: 0.75rem; margin: 0 0.03rem"
                ></el-input>
              </div>
              <div class="searchbutton" @click="query">查询</div>
            </div>
          </div>
        </div>

        <div class="bottom">
          <div
            class="shopproduct"
            v-for="(item, index) in tableData"
            :key="index"
          >
            <shopproduct :item="item"></shopproduct>
          </div>
        </div>
        <div class="mainbox-leftBox-goods-bottom">
            <el-pagination
              background
              style="font-size: 0.16rem"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="1"
              :page-sizes="[20, 50, 100, 200]"
              :page-size="20"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
            >
            </el-pagination>
          </div>
      </div>
    </div>

    <div class="page-bottom">
      <Bottom></Bottom>
    </div>
  </div>
</template>

<script>
import {
  pmsStore,
  pmsStoreB,
  selectCategoryByStoreId,
  selectAllByParamsOnStoreByStoreId
} from '@/api/shopDetail'
import { selectStoreDecorateByStoreId } from '@/api/shopMange'
import shopheader from '../detail/components/shopheader.vue'
import shopmsg from './components/shopmsg.vue'
import shoptab from './components/shoptab.vue'
import shopdetail from './components/shopdetail.vue'
import shopproduct from './components/shopproduct.vue'
import Bottom from '../../components/bottom'
export default {
  components: {
    shopheader,
    shopmsg,
    shoptab,
    shopdetail,
    shopproduct,
    Bottom
  },

  data () {
    return {
      input: '',
      input1: '',
      itemlist: [],
      activeIndex: 0,
      screenlist: ['综合', '人气', '最新'],
      screenindex: 0,
      storeData: {},
      form: {},
      tableData: [],
      total: null,
      params: {
        pageNumber: 1,
        pageSize: 20,
        categoryId: null,
        goodsName: '',
        priceRange: '',
        orderBy: '',
        storeId: this.$route.query.id,
        type: 0
      },
      newType: 0,
      priceRange:''
    }
  },
  created () {
    if(this.$route.query.goodsName){
      this.params.goodsName=this.$route.query.goodsName
    }
    this.pmsStore()
    this.selectStoreDecorateByStoreId()
    this.selectCategoryByStoreId()
    this.selectAllByParamsOnStoreByStoreId()
    
  },
  methods: {
    // 查询
    query () {
      if (this.input !== '' && this.input1 !== '') {
        this.params.priceRange = `${this.input}-${this.input1}`
        this.priceRange = `${this.input}-${this.input1}`
        this.selectAllByParamsOnStoreByStoreId()
        this.selectCategoryByStoreId()
      }
    },
    // 类型查询
    getLx (index) {
      this.screenindex = index
      this.params.orderBy = index
      this.selectAllByParamsOnStoreByStoreId()
    },
    // 分类查询
    getType (item, index) {
      this.activeIndex = index
      this.params.categoryId = item.categoryId
      this.selectAllByParamsOnStoreByStoreId()
    },
    // 获取店铺详情商品列表
    selectAllByParamsOnStoreByStoreId () {
      selectAllByParamsOnStoreByStoreId(this.params).then((data) => {
        this.tableData = data.data.records
        this.total = data.data.total
      })
    },
    handleSizeChange(val) {
      this.params.pageSize = val;
      this.selectAllByParamsOnStoreByStoreId();
    },
    handleCurrentChange(val) {
      this.params.pageNumber = val;
      this.selectAllByParamsOnStoreByStoreId();
    },
    // 获取店铺详情分类
    selectCategoryByStoreId () {
      console.log(this.newType)
      selectCategoryByStoreId({
        storeId: this.$route.query.id,
        type: this.newType,
        priceRange:this.priceRange
      }).then((data) => {
        this.itemlist = data.data
      })
    },
    // 获取供应商信息
    pmsStore (id) {
      pmsStoreB(this.$route.query.id).then((data) => {
        this.storeData = data.data
      })
    },
    // 获取店铺装修信息
    selectStoreDecorateByStoreId () {
      selectStoreDecorateByStoreId({
        storeId: this.$route.query.id
      }).then((data) => {
        this.form = data.data
      })
    }
  }
}
</script>

<style scoped lang="scss">
.main {
  width: 100%;
  height: auto;
  background-color: #f5f7f9;
  .headerbox {
    width: 100%;
    height: 1.74rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background-color: #ffffff;
    .header {
      width: 84%;
      height: 0.42rem;
      background-color: #ffffff;
    }
    .shopmsg {
      width: 100%;
      height: 1.1rem;
    }
    .tab {
      width: 100%;
      height: 0.32rem;
      background: #ec6c15;
    }
  }
  .headeImg {
    margin: 0.2rem auto 0 auto;
    width: 12rem;
    height: 280px;
    img {
      width: 100%;
      height: 280px;
    }
  }
  .notifybox {
    margin: 0.18rem auto 0 auto;
    width: 12rem;
    height: 1.8rem;
    background: #efe6e1;
    position: relative;
    .line {
      width: 11.24rem;
      height: 1.16rem;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translateX(-50%) translateY(-50%);
    }
    .laba {
      width: 0.4rem;
      height: 0.4rem;
      position: absolute;
      left: 5.1rem;
      top: 0.1rem;
    }
    .notify {
      width: 0.96rem;
      height: auto;
      position: absolute;
      left: 5.6rem;
      top: 0.2rem;
    }
    .text {
      width: 10rem;
      height: auto;
      text-align: center;
      position: absolute;
      top: 0.8rem;
      left: 50%;
      transform: translateX(-50%);
      font-size: 0.16rem;
      color: #000000;
    }
  }
  .tuijianbox {
    margin: 0.18rem auto 0 auto;
    width: 12rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    .header {
      width: 100%;
      height: 0.6rem;
      background: #ffffff;
      border-bottom: 0.02rem solid #ec6c15;
      position: relative;
      img {
        width: 0.96rem;
        height: auto;
        position: absolute;
        // top: 0.21rem;
        top: 50%;
        transform: translateY(-50%);
        left: 0.17rem;
      }
      .text {
        position: absolute;
        top: 0.24rem;
        left: 1.39rem;
        font-size: 0.14rem;
        color: #999999;
      }
    }
    .no {
      width: 100%;
      height: 0.18rem;
      background: #ffffff;
    }
    .productbox {
      width: 100%;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      margin-top: 0.1rem;
      .tuiojianproduct {
        width: 2.18rem;
        height: 3.1rem;
        background: #ffffff;
        margin:0.1rem 0.1rem;
      }
    }
  }
  .bottombox {
    margin: 0.4rem auto;
    width: 12rem;
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    .leftmsg {
      width: 2.18rem;
      height: 4.08rem;
    }
    .right {
      width: 9.31rem;
      min-height: 5rem;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      .header {
        width: 100%;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        border: 0.01rem solid #e8e8e8;
        .top {
          width: 100%;
          //height: 0.6rem;
          border-bottom: 1px solid #ec6c15;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          flex-wrap: wrap;
          .item {
            width: auto;
            height: 0.3rem;
            line-height: 0.3rem;
            text-align: center;
            padding: 0 0.2rem;
            border-right: 1px solid #e8e8e8;
            font-size: 0.14rem;
            color: #666666;
            cursor: pointer;
          }
          .activeitem {
            color: #ec6c15;
          }
        }
        .screen {
          font-family: PingFang SC;
          font-size: 0.12rem;
          color: #666666;
          display: flex;
          align-items: center;
          width: 100%;
          height: 0.42rem;
          border: 0.01rem solid #e8e8e8;
          border-top: none;
          .rightbox {
            margin-left: 0.2rem;
            display: flex;
            align-items: center;
            .search {
              width: auto;
              height: 0.4rem;
              font-size: 0.13rem;
              line-height: 0.4rem;
              display: flex;
              align-items: center;
              /deep/.el-input__inner {
                height: 0.25rem !important;
                font-size: 0.12rem;
              }
              .inputStyle {
              }

              &-button {
                cursor: pointer;
                margin-left: 0.1rem;
                width: 0.5rem;
                height: 0.25rem;
                line-height: 0.22rem;
                text-align: center;
                background: #e3e3e3;
                box-sizing: border-box;
                border: 0.01rem solid rgba(0, 0, 0, 0);
              }
            }
            .zdj {
              width: 0.8325rem;
              height: 0.23rem;
              background: #ebebeb;
              font-family: PingFang SC;
              font-size: 0.12rem;
              color: #a7adb8;
              line-height: 0.28rem;
              padding-left: 0.05rem;
              margin-right: 0.02rem;
            }
            .zgj {
              width: 0.8325rem;
              height: 0.23rem;
              background: #ebebeb;
              font-family: PingFang SC;
              font-size: 0.12rem;
              color: #a7adb8;
              line-height: 0.28rem;
              padding-left: 0.05rem;
              margin-left: 0.02rem;
            }
            .searchbutton {
              width: 0.61rem;
              height: 0.28rem;
              background: #ec6c15;
              margin-left: 0.0711rem;
              font-family: PingFang SC;
              font-size: 0.12rem;
              color: #ffffff;
              text-align: center;
              line-height: 0.28rem;
              cursor: pointer;
            }
          }
          .leftbox {
            cursor: pointer;
            position: relative;
            height: 0.32rem;
            width: 1rem;
            text-align: center;
            line-height: 0.32rem;
            // background-color: yellow;
            border-right: 0.01rem solid #e8e8e8;
            .sanjiao {
              position: absolute;
              top: 0.01rem;
              right: 0.1rem;
              display: flex;
              flex-direction: column;
              align-items: center;
              .topsnjiao {
                cursor: pointer;
                width: 0;
                height: 0;
                border: 0.08rem solid;
                border-color: transparent transparent #d8d8d8;
                // margin-bottom: 5px;
              }
              .bottomsanjiao {
                cursor: pointer;
                width: 0;
                height: 0;
                border: 0.08rem solid;
                margin-top: 0.0167rem;
                border-color: #d8d8d8 transparent transparent transparent;
              }
              .isSan {
                border-color: transparent transparent #ec6c15;
              }
              .isSanB {
                border-color: #ec6c15 transparent transparent transparent;
              }
            }
          }
          .isactive {
            color: #ec6c15;
            font-weight: 600;
          }
          .leftbox:last-child {
            border-right: none;
          }
        }
      }
      .bottom {
        padding-bottom: 0.14rem;
        width: 100%;
        height: auto;
        display: flex;
        // justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        .shopproduct {
          margin-top: 0.2rem;
          width: 2.18rem;
          height: 3.1rem;
          background: #ffffff;
          margin-right: 0.1rem;
        }
      }
      ::v-deep
            .el-pagination.is-background
            .el-pager
            li:not(.disabled).active {
            background-color: #e22a1f !important;
          }
          ::v-deep .el-pager li {
            width: 0.4rem !important;
            height: 0.4rem !important;
            line-height: 0.4rem !important;
            border-radius: 0.04rem !important;
          }

          ::v-deep .el-pagination span {
            height: 0.4rem !important;
            line-height: 0.4rem !important;
          }
          ::v-deep .el-pagination button {
            width: 0.4rem !important;
            height: 0.4rem !important;
            line-height: 0.4rem !important;
            border-radius: 0.04rem !important;
          }
    }
  }
  .page-bottom {
    width: 100%;
    height: 3.2rem;
    background: #ffffff;
  }
}
</style>
